<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt' %>--%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<c:set var="title" value="分类管理"/>
<%@include file="common/adminHeader.jsp" %>
<c:set var="light" value="1"/>
<%@include file="common/adminNavigator.jsp" %>
<style>
    #tablelist span {
        height: 80px;
        line-height: 80px;
    }
</style>
<div class="container" >
    <div class="right-top-box">
        <div class="btn bs-bars">
            <a class="btn-product" id="btn_add" title="添加">
                <i class="fa fa-plus fa-fw"></i>
            </a>
            <a class="btn-delete" id="btn_delete_ids" title="批量删除">
                <i class="fa fa-trash-o fa-fw"></i>
            </a>
        </div>
        <div class="row" id="tb">
            <div class="col-md-12">
                <form class="form-inline" id="resource-form">
                    <div class="group-inner">
                        <input type="text" class="form-control form-input" id="search-id" name="search-id" placeholder="ID">
                    </div>
                    <div class="group-inner">
                        <input type="text" class="form-control form-input" id="search-name" name="search-name"  placeholder="名称">
                    </div>
                    <div class="group-inner">
                        <input type="text" class="form-control form-input" id="search-parent_id" name="search-parent_id" placeholder="分类ID">
                    </div>
                    <a class="btn btn-info glyphicon glyphicon-search form-search group-inner" id="btnSearch" >
                    </a>
                </form>
            </div>
        </div>
    </div>
    <div class="modal fade" id="addOrUpdateModal" tabindex="-1" role="dialog" aria-labelledby="addroleLabel" data-backdrop="static" aria-hidden="false">
        <div class="modal-backdrop fade"></div>
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="addroleLabel">修改分类</h4>
                </div>
                <div class="modal-body">
                    <form id="addOrUpdateForm" class="form-horizontal form-label-left" novalidate="">
                        <input type="hidden" name="id" id="id">
                        <input type="hidden" name="shop_id" id="shop_id">
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="parent_id">父类<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
<%--                                <c:if test="${empty categories}">--%>
<%--                                    <input type="text" class="form-control col-md-7 col-xs-12" name="parent_id" id="parent_id" required="required" placeholder="请输入父类">--%>
<%--                                </c:if>--%>
                                <c:if test="${!empty categories}">
                                    <select id="parent_id" name="parent_id" class="form-control">
                                        <c:forEach items="${categories}" var="Categories">
                                            <option value="${Categories.id}">${Categories.name}</option>
                                        </c:forEach>
                                    </select>
                                </c:if>
                            </div>
                        </div>
<%--                        <sec:authorize access="hasRole('ADMIN')">--%>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">类别名称</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="text" class="form-control col-md-7 col-xs-12" id="name" name="name" placeholder="请输入类别名称">
                            </div>
                        </div>
<%--                        </sec:authorize>--%>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="status">类别状态</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <select class="form-control" name="status" id="status">
<%--                                    <option value="1" selected disabled>请选择</option>--%>
                                    <option value="1">上线</option>
                                    <option value="0">下线</option>
                                </select>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="sort_order">排序编号</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="text" class="form-control col-md-7 col-xs-12" name="sort_order" id="sort_order" data-validate-length-range="0,20" placeholder="请输入排序编号">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"> 关闭</i></button>
                    <button type="button" class="btn btn-success addOrUpdateBtn"><i class="fa fa-save">保存</i></button>
                </div>
            </div>
        </div>
    </div>
    <table id="tablelist"></table>
    <script type="text/javascript" src="render/js/manager/common.js"></script>
    <script type="text/javascript" src="render/js/manager/categoryManager.js"></script>
</div>
<script>
    $(function () {
        //当前id
        // var current_id=$("#parent_id").find("option");
        // for (var i=1;i<current_id.length;i++){
        //     $("#parent_id option[index='"+i+"']").val=''+i;
        //     console.log(i+":"+$("#parent_id option[index='"+i+"']").val);
        // }
    });
</script>
<%@include file="common/adminFooter.jsp" %>
